package com.derbysoft.synxisadapter.commons.protocoltest;

import com.derbysoft.synxisadapter.commons.dto.synxis.OTACancelRQ;
import com.derbysoft.synxisadapter.commons.dto.synxis.OTACancelRS;
import com.derbysoft.synxisadapter.commons.dto.synxis.OTAHotelAvailRQ;
import com.derbysoft.synxisadapter.commons.dto.synxis.OTAHotelAvailRS;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StopWatch;

/**
 * Created by: jason
 * Date: 2012-06-19
 */
public class Launching extends AbstractWebServiceTest {
    private static Logger logger = LoggerFactory.getLogger(Launching.class);

    public Launching() {
        initMarshaller();
    }

    public static void main(String[] args) {
        new Launching().getAvailability();
    }

    private void getCancellation() {
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();

        OTACancelRQ request = (OTACancelRQ) JaxbUtils.unmarshal(sampleXml("OTA.Cancel.RQ.01.xml"), marshaller);
        logger.info(LogUtils.toXML(request));
        logger.info(LogUtils.toXML(request));

        OTACancelRS otaCancelRS = (OTACancelRS) invoke(request);
        logger.info(LogUtils.toXML(otaCancelRS));

        stopWatch.stop();
        logger.info(String.valueOf(stopWatch.getTotalTimeMillis()));
    }

    private void getAvailability() {
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();

        OTAHotelAvailRQ request = (OTAHotelAvailRQ) JaxbUtils.unmarshal(sampleXml("HotelBeds.OTA.AvailRQ.xml"), marshaller);
        System.out.println(LogUtils.toXML(request));

        OTAHotelAvailRS otaHotelAvailRS = (OTAHotelAvailRS) invoke(request);
        System.out.println(LogUtils.toXML(otaHotelAvailRS));

        stopWatch.stop();
        logger.info(String.valueOf(stopWatch.getTotalTimeMillis()));
    }
}
